package com.ruoyi.web.controller.snmp;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SnmpCoolmibs;
import com.ruoyi.system.service.ISnmpCoolmibsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 *  Controller
 *
 * @author ruoyi
 * @date 2025-02-05
 */
@RestController
@RequestMapping("/snmp/coolmibs")
public class SnmpCoolmibsController extends BaseController
{
    @Autowired
    private ISnmpCoolmibsService snmpCoolmibsService;

    /**
     * 查询 列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:coolmibs:list')")
    @GetMapping("/list")
    public TableDataInfo list(SnmpCoolmibs snmpCoolmibs)
    {
        startPage();
        List<SnmpCoolmibs> list = snmpCoolmibsService.selectSnmpCoolmibsList(snmpCoolmibs);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:coolmibs:export')")
    @Log(title = " ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SnmpCoolmibs snmpCoolmibs)
    {
        List<SnmpCoolmibs> list = snmpCoolmibsService.selectSnmpCoolmibsList(snmpCoolmibs);
        ExcelUtil<SnmpCoolmibs> util = new ExcelUtil<SnmpCoolmibs>(SnmpCoolmibs.class);
        util.exportExcel(response, list, " 数据");
    }

    /**
     * 获取 详细信息
     */
    @PreAuthorize("@ss.hasPermi('snmp:coolmibs:query')")
    @GetMapping(value = "/{oid}")
    public AjaxResult getInfo(@PathVariable("oid") String oid)
    {
        return success(snmpCoolmibsService.selectSnmpCoolmibsByOid(oid));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('snmp:coolmibs:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SnmpCoolmibs snmpCoolmibs)
    {
        return toAjax(snmpCoolmibsService.insertSnmpCoolmibs(snmpCoolmibs));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('snmp:coolmibs:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SnmpCoolmibs snmpCoolmibs)
    {
        return toAjax(snmpCoolmibsService.updateSnmpCoolmibs(snmpCoolmibs));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('snmp:coolmibs:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{oids}")
    public AjaxResult remove(@PathVariable String[] oids)
    {
        return toAjax(snmpCoolmibsService.deleteSnmpCoolmibsByOids(oids));
    }
}
